<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>
    <div id="app">
        <button v-on:click="count++">{{count}}</button>
        <button v-on:click="addCount">{{count}}</button>
        <input type="text" v-model="msg">
        <div>{{arr}}</div>
        <div>{{obj.name}}-{{obj.age}}</div>
    </div>


    <!-- 引入vue -->
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script>
        const { createApp, ref } = Vue;
        // 创建Vue实例
        const app = createApp({
            setup() {
                // 声明一个响应式状态
                // ref函数接受任意类型的参数，并返回一个响应式对象
                const count = ref(1)
                const msg = ref("hello")
                const arr = ref([1, 2, 3])
                const obj = ref({
                    name: "张三",
                    age: 20
                })

                const addCount = () => {
                    // console.log(count.value);
                    count.value++
                    console.log(obj.value.name);

                }
                return {
                    count,
                    msg,
                    arr,
                    obj,
                    addCount
                }
            }
        })
        // 挂载到dom
        app.mount('#app')
    </script>
</body>

</html>